import { createFromIconfontCN } from "@ant-design/icons-vue";
import { defineComponent, h } from "vue";
import scriptUrl from "./scriptUrl";

const Icon = createFromIconfontCN({ scriptUrl });

const CustomIcon = defineComponent({
  name: "custom-icon",
  props: {
    type: { required: true, type: String },
    spin: { type: Boolean },
    rotate: { type: Number },
    size: { type: String },
  },
  setup(props) {
    return () => <Icon type={props.type} spin={props.spin} rotate={props.rotate} style={{ fontSize: props.size }} />;
  },
});

export default CustomIcon;

export const renderCustomIcon = (type: string, isColor?: boolean) => h(CustomIcon, { type, isColor });
export { renderCustomIcon as hci };
